﻿using Abp.TestBase;
using Castle.MicroKernel.Registration;
using GN.Pay.EntityFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Data.Common;

namespace GN.Pay.UnitTest
{
    /// <summary>
    /// Abp测试基类
    /// </summary>
    public abstract class AbpTestBase : AbpIntegratedTestBase<PayTestModule>
    {
        static AbpTestBase()
        {
            //初始化
        }

        protected AbpTestBase()
        {
             
        }

        protected void CallContext(Action<PayDbContext> action)
        {
            var context = LocalIocManager.Resolve<PayDbContext>();
                            
                action(context);
                context.SaveChanges();
        }

        protected async Task<int> CallContextAsync(Action<PayDbContext> action)
        {
            using (var context = LocalIocManager.Resolve<PayDbContext>())
            {
                action(context);
               return await context.SaveChangesAsync();
            }
        }
    }
}
